import { defHttp } from '/@/utils/http/axios';
import { PageResult } from '@/api/model/pageResult';
import { SortPageVo } from '@/api/model/sortPageVo';
import { SysFileBo } from '@/api/system/file/model/sysFileBo';
import { ContentTypeEnum } from '@/enums/httpEnum';

const baseUrl = '/system/file';
const region = 'cloud-api';

/**
 * 查询列表
 */
export function query(params: SortPageVo): Promise<PageResult<SysFileBo>> {
  console.log('file - query', params);
  return defHttp.get<PageResult<SysFileBo>>({
    url: baseUrl + '/page',
    params,
  });
}

export function uploadImage(file: Blob): Promise<string> {
  return defHttp.post<string>(
    {
      url: baseUrl + '/upload',
      data: file,
    },
    {
      contentType: ContentTypeEnum.BLOB,
      region,
    },
  );
}
